import time
from selenium import webdriver
from selenium.webdriver.common.by import By
import os
# 导入select类
from selenium.webdriver.support.ui import Select

# 打开访问地址
driver = webdriver.Chrome()
url = 'file:///' + os.path.abspath(('html') + '/注册实例.html')
driver.get(url)

# 创建select对象,参数是要操作的select标签
s1 = driver.find_element(By.ID, 'select')
select = Select(s1)

# 选择option
time.sleep(2)
select.select_by_index(1)
time.sleep(2)
select.select_by_value('bj')
time.sleep(2)
select.select_by_visible_text('上海')

driver.quit()